# +----------------------------------------------------------------------
# | ChatWork
# +----------------------------------------------------------------------
# | 这不是一个自由软件,您只能在不用于商业目的的前提下对程序代码进行修改和使用。
# | 任何企业和个人不允许对程序代码以任何形式任何目的再发布,商业使用请获取授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import List
from fastapi import Query
from pydantic import BaseModel, Field


class RobotInstructSearchIn(BaseModel):
    """ 指令搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    bot: str = Query(..., min_length=1, max_length=32, description="智能体编号")


class RobotInstructAddIn(BaseModel):
    """ 指令新增参数 """
    bot: str = Field(..., min_length=1, max_length=32, description="智能体Code")
    scene: str = Field(..., pattern=r"^(fixed|direct)$", description="场景: [fixed=固定, direct=指令]")
    keyword: str = Field(..., min_length=1, max_length=200, description="关键词")
    content: str = Field(..., min_length=1, max_length=65535, description="答复内容")
    annex: List[dict] = Field(default=[], description="上传附件")

    class Config:
        json_schema_extra = {
            "example": {
                "bot": "pdr4ah5nbs0ul6ti",
                "scene": "fixed",
                "keyword": "关键词",
                "content": "内容",
                "annex": {
                    "file_type": "file",
                    "file_name": "交易合同.pdf",
                    "file_size": 2685,
                    "file_ext": "pdf",
                    "file_path": "https://www.a.cn/a.pdf"
                }
            }
        }


class RobotInstructEditIn(BaseModel):
    """ 指令新增参数 """
    id: int = Field(..., gt=0, description="ID")
    bot: str = Field(..., min_length=1, max_length=32, description="智能体Code")
    scene: str = Field(..., pattern=r"^(fixed|direct)$", description="场景: [fixed=固定, direct=指令]")
    keyword: str = Field(..., min_length=1, max_length=200, description="关键词")
    content: str = Field(..., min_length=1, max_length=65535, description="答复内容")
    annex: List[dict] = Field(default=[], description="上传附件")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "bot": "pdr4ah5nbs0ul6ti",
                "scene": "fixed",
                "keyword": "关键词",
                "content": "内容",
                "annex": {
                    "file_type": "file",
                    "file_name": "交易合同.pdf",
                    "file_size": 2685,
                    "file_ext": "pdf",
                    "file_path": "https://www.a.cn/a.pdf"
                }
            }
        }


class RobotInstructDeleteIn(BaseModel):
    """ 指令删除参数 """
    id: int = Field(..., gt=0, description="ID")
    bot: str = Field(..., min_length=1, max_length=32, description="智能体Code")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "bot": "pdr4ah5nbs0ul6ti"
            }
        }


"""--------------- Separator ---------------"""


class RobotInstructListVo(BaseModel):
    """ 指令列表VO """
    id: int = Field(description="ID")
    scene: str = Field(description="场景: [fixed=固定, direct=指令]")
    keyword: str = Field(description="关键词")
    content: str = Field(description="答复内容")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")
    annex: List[dict] = Field(description="上传附件")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "scene": "fixed",
                "keyword": "关键词",
                "content": "内容",
                "create_time": "2025-01-24 14:04:46",
                "update_time": "2025-01-24 14:06:23",
                "annex": {
                    "file_type": "file",
                    "file_name": "交易合同.pdf",
                    "file_size": 2685,
                    "file_ext": "pdf",
                    "file_path": "https://www.a.cn/a.pdf"
                }
            }
        }
